﻿/* * 版 本 PIT-ADMS V7.0.3 敏捷开发框架
 * Copyright (c) 2013-2018 Hexagon PPM
 * 创建人：超级管理员
 * 日  期：2022-03-07 13:44
 * 描  述：工程数据表
 */
var refreshGirdData;
var ProjectId = parent.request('ProjectId');
var bootstrap = function ($, learun) {
    "use strict";
    var page = {
        init: function () {
            page.initGird();
            page.bind();
        },
        bind: function () {
            $('#UpObjectTypeID').lrselect({
                url: top.$.rootUrl + '/ZZDT_EC/ec_objecttype/GetTreeData',
                param: { ProjectId: ProjectId, isShowCheck: false },
                type: 'tree',
                allowSearch: true,
                maxHeight: 225
            });
            $('#DataStatus').lrDataItemSelect({ code: 'Be_DataStatus' });
            //查询
            $('#btn_Search').on('click', function () {
                page.search($('.lr-layout-tool-left').lrGetFormData());
            });
            // 刷新
            $('#lr_refresh').on('click', function () {
                location.reload();
            });
            // 删除
            $('#lr_delete').on('click', function () {
                var rowdata = $('#gridtable').jfGridGet('rowdata');
                if (rowdata.length != 1) {
                    learun.alert.warning('请勾选一条数据项再操作！');
                    return false;
                }
                learun.layerConfirm('是否确认删除该项！', function (res) {
                    if (res) {
                        learun.deleteForm(top.$.rootUrl + '/ZZDT_EC/ec_enginedata/DeleteForm', { keyValue: rowdata[0].EngineDataID, ProjectId: ProjectId }, function () {
                            refreshGirdData();
                        });
                    }
                });
            });
        },
        // 初始化列表
        initGird: function () {
            $('#gridtable').jfGrid({
                url: top.$.rootUrl + '/ZZDT_EC/ec_enginedata/GetRecycleBinPageList',
                headData: [
                    { label: "位号", name: "TagNumber", width: 300, align: "center", sort: false },
                    { label: "对象类型", name: "FullPathCN", width: 300, align: "center", sort: false },
                    { label: "数据状态", name: "DataStatusName", width: 150, align: "center", sort: false },
                    { name: "", width: 1, sort: false }
                ],
                mainId: 'EngineDataID',
                isPage: true,
                isMultiselect: true,
            });
            page.search();
        },
        search: function (param) {
            param = param || {};
            if (param.UpObjectTypeID == "-1") {
                param.UpObjectTypeID = "";
            }
            param.ProjectId = ProjectId;
            $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
        }
    };
    refreshGirdData = function () {
        $('#gridtable').jfGridSet('reload');
    };
    page.init();
}
